package com.starbaba.buriedPoint.view;

import java.io.IOException;
import java.util.List;

import com.base.common.log.LogService;
import com.opensymphony.xwork2.ModelDriven;
import com.starbaba.buriedPoint.service.BuriedPointDisplayService;
import com.starbaba.buriedPoint.service.impl.BuriedPointDisplayServiceImpl;
import com.starbaba.core.utils.PropertyParamMapBuilder;
import com.starbaba.core.utils.Struts2Utils;
import com.starbaba.core.utils.json.JsonUtils;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.core.web.struts2.BaseAction;
import com.tuanzi.server.loan_base.model.db.buriedpoint.BuriedPoint;

/**
 * 埋点数据实时展示后台 action
 * @author chenweijun
 *
 */
@SuppressWarnings({"unchecked","rawtypes","serial"})
public class BuriedPointDisplayAction extends BaseAction implements ModelDriven<BuriedPoint>{
	
	private BuriedPoint model;
	private BuriedPointDisplayService service;
	

	public BuriedPointDisplayAction(){
		this.service = new BuriedPointDisplayServiceImpl();
	}

	@Override
	public BuriedPoint getModel() {
		if(model == null){
			model = new BuriedPoint();
		}
		return model;
	}
	
	
	/**
	 * 查询列表
	 */
	public void getList(){
	
		parsePageRequest();
		PageResponse pageResponse=new PageResponse();
		paramsMap=PropertyParamMapBuilder.buildFromHttpRequest(Struts2Utils.getRequest(), paramsMap);
		List<BuriedPoint> list=service.getList(paramsMap, pageRequest.getIDisplayStart(), pageRequest.getIDisplayLength());
		int count=service.countList(paramsMap);
		try {
			
			pageResponse.setITotalDisplayRecords(count);
			pageResponse.setITotalRecords(count);
			pageResponse.setAaData(list);
			sendJsonMessage(JsonUtils.toJson(pageResponse, null, true, null, false));
			
		} catch(IOException e) {
			LogService.error(e);
		}
		
	}
	
	
}
